package tt.dz.order.pojo;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import tt.dz.order.dao.BaseDAOUtil;

/**
 * @Title 微信充电预约退款返回记录
 * @author zhoutian   
 * @date 2015-11-26
 */
public class WeiXinRefundReturnRecord {
	//商户系统唯一订单号
	private String orderNo;
	//返回状态码，SUCCESS/FAIL
	private String returnCode;
	//返回信息，如非空，为错误原因
	private String returnMsg;
	//业务结果，SUCCESS/FAIL SUCCESS退款申请接收成功，结果通过退款查询接口查询 FAIL 提交业务失败
	private String resultCode;
	//错误代码,错误返回的信息描述
	private String errCode;
	//错误代码描述,错误返回的信息描述
	private String errCodeDes;
	//公众账号ID,微信分配的公众账号ID（企业号corpid即为此appId）
	private String appId;
	//商户号,微信支付分配的商户号
	private String partnerNo;
	//设备号,微信支付分配的终端设备号，与下单一致
	private String deviceInfo;
	//随机字符串，不长于32位
	private String nonceStr;
	//签名,用于验证回调请求参数是否被篡改过
	private String sign;
	//微信订单号
	private String tradeNo;
	//商户退款单号
	private String outRefundNo;
	//微信退款单号
	private String refundId;
	//退款渠道,ORIGINAL—原路退款 BALANCE—退回到余额
	private String refundChannel;
	//退款金额,退款总金额,单位为分,可以做部分退款
	private String refundFee;
	//订单总金额，单位为分，只能为整数
	private String totalFee;
	//订单金额货币类型，符合ISO 4217标准的三位字母代码，默认人民币：CNY
	private String feeType;
	//现金支付金额，单位为分，只能为整数
	private String cashFee;
	//现金退款金额，单位为分，只能为整数
	private String cashRefundFee;
	//代金券或立减优惠退款金额,等于订单金额-现金退款金额，注意：立减优惠金额不会退回
	private String couponRefundFee;
	//代金券或立减优惠使用数量
	private String couponRefundCount;
	//代金券或立减优惠ID
	private String couponRefundId;
	//创建时间
	private Date createTime;

	public String getOrderNo() {
		return orderNo;
	}

	public void setOrderNo(String orderNo) {
		this.orderNo = orderNo;
	}

	public String getReturnCode() {
		return returnCode;
	}

	public void setReturnCode(String returnCode) {
		this.returnCode = returnCode;
	}

	public String getReturnMsg() {
		return returnMsg;
	}

	public void setReturnMsg(String returnMsg) {
		this.returnMsg = returnMsg;
	}

	public String getResultCode() {
		return resultCode;
	}

	public void setResultCode(String resultCode) {
		this.resultCode = resultCode;
	}

	public String getErrCode() {
		return errCode;
	}

	public void setErrCode(String errCode) {
		this.errCode = errCode;
	}

	public String getErrCodeDes() {
		return errCodeDes;
	}

	public void setErrCodeDes(String errCodeDes) {
		this.errCodeDes = errCodeDes;
	}

	public String getAppId() {
		return appId;
	}

	public void setAppId(String appId) {
		this.appId = appId;
	}

	public String getPartnerNo() {
		return partnerNo;
	}

	public void setPartnerNo(String partnerNo) {
		this.partnerNo = partnerNo;
	}

	public String getDeviceInfo() {
		return deviceInfo;
	}

	public void setDeviceInfo(String deviceInfo) {
		this.deviceInfo = deviceInfo;
	}

	public String getNonceStr() {
		return nonceStr;
	}

	public void setNonceStr(String nonceStr) {
		this.nonceStr = nonceStr;
	}

	public String getSign() {
		return sign;
	}

	public void setSign(String sign) {
		this.sign = sign;
	}

	public String getTradeNo() {
		return tradeNo;
	}

	public void setTradeNo(String tradeNo) {
		this.tradeNo = tradeNo;
	}

	public String getOutRefundNo() {
		return outRefundNo;
	}

	public void setOutRefundNo(String outRefundNo) {
		this.outRefundNo = outRefundNo;
	}

	public String getRefundId() {
		return refundId;
	}

	public void setRefundId(String refundId) {
		this.refundId = refundId;
	}

	public String getRefundChannel() {
		return refundChannel;
	}

	public void setRefundChannel(String refundChannel) {
		this.refundChannel = refundChannel;
	}

	public String getRefundFee() {
		return refundFee;
	}

	public void setRefundFee(String refundFee) {
		this.refundFee = refundFee;
	}

	public String getTotalFee() {
		return totalFee;
	}

	public void setTotalFee(String totalFee) {
		this.totalFee = totalFee;
	}

	public String getFeeType() {
		return feeType;
	}

	public void setFeeType(String feeType) {
		this.feeType = feeType;
	}

	public String getCashFee() {
		return cashFee;
	}

	public void setCashFee(String cashFee) {
		this.cashFee = cashFee;
	}

	public String getCashRefundFee() {
		return cashRefundFee;
	}

	public void setCashRefundFee(String cashRefundFee) {
		this.cashRefundFee = cashRefundFee;
	}

	public String getCouponRefundFee() {
		return couponRefundFee;
	}

	public void setCouponRefundFee(String couponRefundFee) {
		this.couponRefundFee = couponRefundFee;
	}

	public String getCouponRefundCount() {
		return couponRefundCount;
	}

	public void setCouponRefundCount(String couponRefundCount) {
		this.couponRefundCount = couponRefundCount;
	}

	public String getCouponRefundId() {
		return couponRefundId;
	}

	public void setCouponRefundId(String couponRefundId) {
		this.couponRefundId = couponRefundId;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public WeiXinRefundReturnRecord(){
		
	}
	
	public WeiXinRefundReturnRecord(Map<String, Object> callBackMap){
		this.orderNo = (String) callBackMap.get("out_trade_no");
		this.returnCode = (String) callBackMap.get("return_code");
		this.returnMsg = (String) callBackMap.get("return_msg");
		this.resultCode = (String) callBackMap.get("result_code");
		this.errCode = (String) callBackMap.get("err_code");
		this.errCodeDes = (String) callBackMap.get("err_code_des");
		this.appId = (String) callBackMap.get("appid");
		this.partnerNo = (String) callBackMap.get("mch_id");
		this.deviceInfo = (String) callBackMap.get("device_info");
		this.nonceStr = (String) callBackMap.get("nonce_str");
		this.sign = (String) callBackMap.get("sign");
		this.tradeNo = (String) callBackMap.get("transaction_id");
		this.outRefundNo = (String) callBackMap.get("out_refund_no");
		this.refundId = (String) callBackMap.get("refund_id");
		this.refundChannel = (String) callBackMap.get("refund_channel");
		this.refundFee = (String) callBackMap.get("refund_fee");
		this.totalFee = (String) callBackMap.get("total_fee");
		this.feeType = (String) callBackMap.get("fee_type");
		this.cashFee = (String) callBackMap.get("cash_fee");
		this.cashRefundFee = (String) callBackMap.get("cash_refund_fee");
		this.couponRefundFee = (String) callBackMap.get("coupon_refund_fee");
		this.couponRefundCount = (String) callBackMap.get("coupon_refund_count");
		this.couponRefundId = (String) callBackMap.get("coupon_refund_id");
		this.createTime = new Date();
	}
	
	public void save(){
		String sql = "insert into Order_WeiXin_Refund_Return_Record(orderNo, returnCode, returnMsg, resultCode, errCode, errCodeDes, appId, partnerNo, deviceInfo, nonceStr, sign, tradeNo, outRefundNo, refundId, refundChannel, refundFee, totalFee, feeType, cashFee, cashRefundFee, couponRefundFee, couponRefundCount, couponRefundId, createTime) values(:orderNo, :returnCode, :returnMsg, :resultCode, :errCode, :errCodeDes, :appId, :partnerNo, :deviceInfo, :nonceStr, :sign, :tradeNo, :outRefundNo, :refundId, :refundChannel, :refundFee, :totalFee, :feeType, :cashFee, :cashRefundFee, :couponRefundFee, :couponRefundCount, :couponRefundId, :createTime)";
		BaseDAOUtil.updateObject(sql, this);
	}
	
	public void update(){
		String sql = "update Order_WeiXin_Refund_Return_Record set orderNo= :orderNo, returnCode = :returnCode, returnMsg = :returnMsg, resultCode = :resultCode, errCode = :errCode, errCodeDes = :errCodeDes, appId = :appId, partnerNo = :partnerNo, deviceInfo = :deviceInfo, nonceStr = :nonceStr, sign = :sign, tradeNo = :tradeNo, outRefundNo = :outRefundNo, refundId = :refundId, refundChannel = :refundChannel, refundFee = :refundFee, totalFee = :totalFee, feeType = :feeType, cashFee = :cashFee, cashRefundFee = :cashRefundFee, couponRefundFee = :couponRefundFee, couponRefundCount = :couponRefundCount, couponRefundId = :couponRefundId, createTime = :createTime where outRefundNo = :outRefundNo";
		BaseDAOUtil.updateObject(sql, this);
	}
	
	public static WeiXinRefundReturnRecord getBy(String outRefundNo){
		String sql = "select orderNo, returnCode, returnMsg, resultCode, errCode, errCodeDes, appId, partnerNo, deviceInfo, nonceStr, sign, tradeNo, outRefundNo, refundId, refundChannel, refundFee, totalFee, feeType, cashFee, cashRefundFee, couponRefundFee, couponRefundCount, couponRefundId, createTime from Order_WeiXin_Refund_Return_Record where outRefundNo = :outRefundNo";
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("outRefundNo", outRefundNo);
		return BaseDAOUtil.queryForObject(sql, paramMap, WeiXinRefundReturnRecord.class);
	}
}
